from pyhive import hive

# 连接Hive
conn = hive.Connection(host="10.128.1.30", port=10000, username="zhaixinda")

# 执行SQL查询
cursor = conn.cursor()
cursor.execute("""
select
event,
upper(distinct_id) as distinct_id
from default.ods_slog t
where day ='20230902'
and event in ('showInteractionService') 
and distinct_id is not null 
and distinct_id <> '' 
and distinct_id not like '00%'
and length(distinct_id)=12
limit 100
""")
results = cursor.fetchall()

# 打印查询结果
for row in results:
    print(row)

# 关闭连接
conn.close()